package com.fr.dialog.core;

import com.fr.base.Inter;
import com.fr.report.ReportPageAttr;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import javax.swing.BorderFactory;
import javax.swing.JCheckBox;
import javax.swing.JFormattedTextField;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSpinner;
import javax.swing.JSpinner.DefaultEditor;
import javax.swing.SpinnerNumberModel;

public class ReportPageAttrPane extends JPanel
{
  private JSpinner overlapRowStartTitleSpinner;
  private JSpinner overlapRowEndTitleSpinner;
  private JSpinner overlapColStartTitleSpinner;
  private JSpinner overlapColEndTitleSpinner;
  private JSpinner overlapRowStartFinisSpinner;
  private JSpinner overlapRowEndFinisSpinner;
  private JSpinner overlapColStartFinisSpinner;
  private JSpinner overlapColEndFinisSpinner;
  private JCheckBox usePageFrozenCCheckBox;
  private JCheckBox usePageFrozenRCheckBox;

  public ReportPageAttrPane()
  {
    setBorder(BorderFactory.createTitledBorder(Inter.getLocText("PageSetup-Overlap_Content")));
    setLayout(new GridLayout(5, 2));
    JPanel localJPanel1 = new JPanel();
    add(localJPanel1);
    localJPanel1.setLayout(new FlowLayout(0, 4, 1));
    localJPanel1.add(new JLabel(Inter.getLocText("PageSetup-Title_Start_Row") + ":"));
    this.overlapRowStartTitleSpinner = new JSpinner(new SpinnerNumberModel(0, -1, 2147483647, 1));
    JFormattedTextField localJFormattedTextField1 = ((JSpinner.DefaultEditor)this.overlapRowStartTitleSpinner.getEditor()).getTextField();
    localJFormattedTextField1.setColumns(4);
    localJPanel1.add(this.overlapRowStartTitleSpinner);
    JPanel localJPanel2 = new JPanel();
    add(localJPanel2);
    localJPanel2.setLayout(new FlowLayout(0, 4, 1));
    localJPanel2.add(new JLabel(Inter.getLocText("PageSetup-Title_End_Row") + ":"));
    this.overlapRowEndTitleSpinner = new JSpinner(new SpinnerNumberModel(0, -1, 2147483647, 1));
    JFormattedTextField localJFormattedTextField2 = ((JSpinner.DefaultEditor)this.overlapRowEndTitleSpinner.getEditor()).getTextField();
    localJFormattedTextField2.setColumns(4);
    localJPanel2.add(this.overlapRowEndTitleSpinner);
    JPanel localJPanel3 = new JPanel();
    add(localJPanel3);
    localJPanel3.setLayout(new FlowLayout(0, 4, 1));
    localJPanel3.add(new JLabel(Inter.getLocText("PageSetup-Title_Start_Column") + ":"));
    this.overlapColStartTitleSpinner = new JSpinner(new SpinnerNumberModel(0, -1, 2147483647, 1));
    JFormattedTextField localJFormattedTextField3 = ((JSpinner.DefaultEditor)this.overlapColStartTitleSpinner.getEditor()).getTextField();
    localJFormattedTextField3.setColumns(4);
    localJPanel3.add(this.overlapColStartTitleSpinner);
    JPanel localJPanel4 = new JPanel();
    add(localJPanel4);
    localJPanel4.setLayout(new FlowLayout(0, 4, 1));
    localJPanel4.add(new JLabel(Inter.getLocText("PageSetup-Title_End_Column") + ":"));
    this.overlapColEndTitleSpinner = new JSpinner(new SpinnerNumberModel(0, -1, 2147483647, 1));
    JFormattedTextField localJFormattedTextField4 = ((JSpinner.DefaultEditor)this.overlapColEndTitleSpinner.getEditor()).getTextField();
    localJFormattedTextField4.setColumns(4);
    localJPanel4.add(this.overlapColEndTitleSpinner);
    JPanel localJPanel5 = new JPanel();
    add(localJPanel5);
    localJPanel5.setLayout(new FlowLayout(0, 4, 2));
    localJPanel5.add(new JLabel(Inter.getLocText("Freeze-Page_Row") + ":"));
    localJPanel5.add(this.usePageFrozenRCheckBox = new JCheckBox());
    JPanel localJPanel6 = new JPanel();
    add(localJPanel6);
    localJPanel6.setLayout(new FlowLayout(0, 4, 2));
    localJPanel6.add(new JLabel(Inter.getLocText("Freeze-Page_Column") + ":"));
    localJPanel6.add(this.usePageFrozenCCheckBox = new JCheckBox());
    JPanel localJPanel7 = new JPanel();
    add(localJPanel7);
    localJPanel7.setLayout(new FlowLayout(0, 4, 1));
    localJPanel7.add(new JLabel(Inter.getLocText("PageSetup-Finis_Start_Row") + ":"));
    this.overlapRowStartFinisSpinner = new JSpinner(new SpinnerNumberModel(0, -1, 2147483647, 1));
    JFormattedTextField localJFormattedTextField5 = ((JSpinner.DefaultEditor)this.overlapRowStartFinisSpinner.getEditor()).getTextField();
    localJFormattedTextField5.setColumns(4);
    localJPanel7.add(this.overlapRowStartFinisSpinner);
    JPanel localJPanel8 = new JPanel();
    add(localJPanel8);
    localJPanel8.setLayout(new FlowLayout(0, 4, 1));
    localJPanel8.add(new JLabel(Inter.getLocText("PageSetup-Finis_End_Row") + ":"));
    this.overlapRowEndFinisSpinner = new JSpinner(new SpinnerNumberModel(0, -1, 2147483647, 1));
    JFormattedTextField localJFormattedTextField6 = ((JSpinner.DefaultEditor)this.overlapRowEndFinisSpinner.getEditor()).getTextField();
    localJFormattedTextField6.setColumns(4);
    localJPanel8.add(this.overlapRowEndFinisSpinner);
    JPanel localJPanel9 = new JPanel();
    add(localJPanel9);
    localJPanel9.setLayout(new FlowLayout(0, 4, 1));
    localJPanel9.add(new JLabel(Inter.getLocText("PageSetup-Finis_Start_Column") + ":"));
    this.overlapColStartFinisSpinner = new JSpinner(new SpinnerNumberModel(0, -1, 2147483647, 1));
    JFormattedTextField localJFormattedTextField7 = ((JSpinner.DefaultEditor)this.overlapColStartFinisSpinner.getEditor()).getTextField();
    localJFormattedTextField7.setColumns(4);
    localJPanel9.add(this.overlapColStartFinisSpinner);
    JPanel localJPanel10 = new JPanel();
    add(localJPanel10);
    localJPanel10.setLayout(new FlowLayout(0, 4, 1));
    localJPanel10.add(new JLabel(Inter.getLocText("PageSetup-Finis_End_Column") + ":"));
    this.overlapColEndFinisSpinner = new JSpinner(new SpinnerNumberModel(0, -1, 2147483647, 1));
    JFormattedTextField localJFormattedTextField8 = ((JSpinner.DefaultEditor)this.overlapColEndFinisSpinner.getEditor()).getTextField();
    localJFormattedTextField8.setColumns(4);
    localJPanel10.add(this.overlapColEndFinisSpinner);
  }

  public void populate(ReportPageAttr paramReportPageAttr)
  {
    if (paramReportPageAttr == null)
      paramReportPageAttr = new ReportPageAttr();
    this.overlapRowStartTitleSpinner.setValue(new Integer(paramReportPageAttr.getRepeatHeaderRowFrom() + 1));
    this.overlapRowEndTitleSpinner.setValue(new Integer(paramReportPageAttr.getRepeatHeaderRowTo() + 1));
    this.overlapColStartTitleSpinner.setValue(new Integer(paramReportPageAttr.getRepeatHeaderColumnFrom() + 1));
    this.overlapColEndTitleSpinner.setValue(new Integer(paramReportPageAttr.getRepeatHeaderColumnTo() + 1));
    this.overlapRowStartFinisSpinner.setValue(new Integer(paramReportPageAttr.getRepeatFooterRowFrom() + 1));
    this.overlapRowEndFinisSpinner.setValue(new Integer(paramReportPageAttr.getRepeatFooterRowTo() + 1));
    this.overlapColStartFinisSpinner.setValue(new Integer(paramReportPageAttr.getRepeatFooterColumnFrom() + 1));
    this.overlapColEndFinisSpinner.setValue(new Integer(paramReportPageAttr.getRepeatFooterColumnTo() + 1));
    this.usePageFrozenCCheckBox.setSelected(paramReportPageAttr.isUsePageFrozenColumn());
    this.usePageFrozenRCheckBox.setSelected(paramReportPageAttr.isUsePageFrozenRow());
  }

  public ReportPageAttr update()
  {
    ReportPageAttr localReportPageAttr = new ReportPageAttr();
    localReportPageAttr.setRepeatHeaderRowFrom(((Integer)this.overlapRowStartTitleSpinner.getValue()).intValue() - 1);
    localReportPageAttr.setRepeatHeaderRowTo(((Integer)this.overlapRowEndTitleSpinner.getValue()).intValue() - 1);
    localReportPageAttr.setRepeatHeaderColumnFrom(((Integer)this.overlapColStartTitleSpinner.getValue()).intValue() - 1);
    localReportPageAttr.setRepeatHeaderColumnTo(((Integer)this.overlapColEndTitleSpinner.getValue()).intValue() - 1);
    localReportPageAttr.setRepeatFooterRowFrom(((Integer)this.overlapRowStartFinisSpinner.getValue()).intValue() - 1);
    localReportPageAttr.setRepeatFooterRowTo(((Integer)this.overlapRowEndFinisSpinner.getValue()).intValue() - 1);
    localReportPageAttr.setRepeatFooterColumnFrom(((Integer)this.overlapColStartFinisSpinner.getValue()).intValue() - 1);
    localReportPageAttr.setRepeatFooterColumnTo(((Integer)this.overlapColEndFinisSpinner.getValue()).intValue() - 1);
    localReportPageAttr.setUsePageFrozenColumn(this.usePageFrozenCCheckBox.isSelected());
    localReportPageAttr.setUsePageFrozenRow(this.usePageFrozenRCheckBox.isSelected());
    return localReportPageAttr;
  }
}